const mysql = require("mysql");
const connection = mysql.createConnection({
  host: "127.0.0.1",
  //post:3306,
  user: "root",
  password: "root",
  database: "albx33"
});

module.exports = {
  validateEmailAndPassword(email, password, callback) {
    let sql = `SELECT * FROM users WHERE email='${email}' AND \`password\`='${password}'`;
    connection.query(sql, (err, result) => {
      callback(err, result[0]);
    });
  },
  getAllUser(callback) {
    // let sql = `SELECT * FROM users WHERE isDelete=0`;
    let sql = "SELECT * FROM users WHERE isDelete=0";
    connection.query(sql, (err, result) => {
      callback(err, result);
    });
  },
  deleteUserById(id, callback) {
    let sql = `UPDATE users SET isDelete=1 WHERE id=${id}`;
    connection.query(sql, (err, result) => {
      callback(err, result);
    });
  }
};
